package com.chinairi.mall.controller;


import com.chinairi.common.utils.ResponseUtil;
import com.chinairi.mall.model.Measurement;
import com.chinairi.mall.service.IMeasurementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.chinairi.common.controller.BaseController;

import java.io.IOException;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Webgasd
 * @since 2020-09-12
 */
@RestController
@RequestMapping("/measurement")
public class MeasurementController extends BaseController {
    @Autowired
    private IMeasurementService iMeasurementService;

    /**
     * 配置计量单位
     * @param measurement
     * @throws IOException
     */
    @PostMapping("/config")
    public void config(Measurement measurement) throws IOException {
        iMeasurementService.config(measurement);
        ResponseUtil.showMessage("success", "特征量表配置成功", null);
    }
    /**
     * 获取特征量列表
     */
    @GetMapping("/getTypeList")
    public void getTypeList() throws IOException {
        List<Measurement> measurementList = iMeasurementService.getTypeList();
        ResponseUtil.showMessage("success", "特征量获取成功", measurementList);
    }

    /**
     * 获取特征量单位列表
     */
    @GetMapping("/getUnitList")
    public void getUnitList(String type) throws IOException {
        List<Measurement> measurementList = iMeasurementService.getUnitList(type);
        ResponseUtil.showMessage("success", "特征量单位获取成功", measurementList);
    }
}
